<template lang="pug">
  el-drawer.commonDrawer(
    title="巡检结果"
    :visible="visibleDialog"
    append-to-body
    center
    destroy-on-close
    direction="rtl"
    size="960px"
    @close="$_handleCancel"
  )
    .drawer-content(v-loading="loading")
      form-info(:items="infoItems")
      s-table(
        ref="table"
        :dataPops="list"
        reqMethod="POST"
        style="padding: 0"
        :column="tableObj.columnConfig"
        :queryPropsParams="{ targetRecordId: id }"
      )
        template(slot="url" slot-scope="text, scope")
          div(v-if="scope.url")
            el-image(:src="scope.url.split(',')[0]" :preview-src-list="scope.url.split(',')" :key="index" style="width: 80px; height: 80px")
            //el-image(v-for="(item, index) in scope.url.split(',')" :src="item" :key="index" style="width: 80px; height: 80px")
          div(v-else)
</template>

<script>
import { checkDetail } from '../api'
import { detailColumnConfig, infoItems } from '../config'
import FormInfo from '@/components/Basic/Form/FormInfo'
export default {
  components: {
    FormInfo
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    id: {
      type: String,
      default: ''
    },
    name: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      loading: false,
      tableObj: {
        columnConfig: detailColumnConfig
      },

      list: [],
      info: {}
    }
  },
  computed: {
    visibleDialog: {
      get () {
        return this.visible
      },
      set (val) {
        this.$emit('update:visible', val)
      }
    },
    infoItems () {
      return infoItems(this.info)
    }
  },
  watch: {
    visible (val) {
      if (val) {
        this.getCheckDetail()
      }
    }
  },
  methods: {
    getCheckDetail () {
      checkDetail({ targetRecordId: this.id }).then(res => {
        console.log(res)
        this.info = {
          name: this.name,
          userName: res.userName,
          recordCount: res.recordCount,
          projectCount: res.projectCount,
          percentage: res.percentage
        }
        this.list = res.list
      })
    },
    $_handleCancel () {
      this.visibleDialog = false
    }
  }
}
</script>

<style scoped>

</style>
